package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    // 插入订单数据
    void insert(Orders orders);
    // 分页查询历史订单
    Page<Orders> historyOrders(OrdersPageQueryDTO ordersPageQueryDTO);

    // 根据id查询订单表
    @Select("select * from orders where id = #{id}")
    Orders selectOrderById(Long id);

    // 更新订单
    void update(Orders orders);

    // 查询所有订单
    @Select("select * from orders")
    List<Orders> selectAllOrder();

    // 查询超时订单
    @Select("select * from orders where status = #{pendingPayment} and order_time < #{orderTime}")
    List<Orders> getByStatusAndOrderTime(Integer pendingPayment, LocalDateTime orderTime);

    //根据动态条件查询营业额
    Double sumAmountByDate(Map map);

    //根据动态条件查询订单数
    Integer getCountByDate(Map map);

    // 获取销量前10的菜品排行榜
    List<GoodsSalesDTO> getSalesTop(LocalDateTime begin,LocalDateTime end);
}
